package com.wenjie.plugin;

import android.content.Context;
import android.widget.Toast;

import com.wenjie.plugin.util.Global;

import io.dcloud.feature.uniapp.annotation.UniJSMethod;
import io.dcloud.feature.uniapp.common.UniModule;

/**
 * 显示Toast
 */
public class ToastModule extends UniModule {

    /**
     * 显示短Toast
     */
    @UniJSMethod(uiThread = true)
    public void showToast(String message) {
        Global global = Global.getInstance();
        Context mContext = global.getContext();

        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
    }

    /**
     * 显示长Toast
     */
    @UniJSMethod(uiThread = true)
    public void showLongToast(String message) {
        Global global = Global.getInstance();
        Context mContext = global.getContext();

        Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
    }
}
